package me.leiusual.sharing.ui.home.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import me.leiusual.sharing.ui.home.HomeSearchProductFragment
import me.leiusual.sharing.ui.home.HomeSearchStoreFragment

/**
 * author: leiusual
 * create on: 2019-07-30
 * description:
 */
class HomeSearchAdapter(
    fragmentManager: FragmentManager
) : FragmentStatePagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

  override fun getCount(): Int {
    return 2
  }

  override fun getPageTitle(position: Int): CharSequence? {
    return when (position) {
      0 -> "商品"
      else -> "店铺"
    }
  }

  override fun getItem(position: Int): Fragment {
    return when (position) {
      0 -> HomeSearchProductFragment()
      else -> HomeSearchStoreFragment()
    }
  }
}